﻿using System.Runtime.Serialization;
using GMME.Model.Rtm.Req;
using UnityEngine;
using UnityEngine.Scripting;

namespace GMME.Model.Rtm.Result
{
    [DataContract]
    public class PublishRtmChannelMessageResult : ErrorResult
    {
        /**
         * 开发者传入的频道Id
         */
        [DataMember(Name = "channelId")]
        [Preserve]
        public string ChannelId { get; set; }

        /**
         * 客户端发送消息唯一标识
         */
        [DataMember(Name = "clientMsgId")]
        [Preserve]
        public string ClientMsgId { get; set; }

        /**
         * 全局发送消息唯一标识
         */
        [DataMember(Name = "serverMsgId")]
        [Preserve]
        public string ServerMsgId { get; set; }

        [DataMember(Name = "request")]
        [Preserve]
        public PublishRtmChannelMessageReq Request { get; set; }

#if UNITY_ANDROID
        internal static PublishRtmChannelMessageResult ConvertPublishRtmChannelMessageResult(
            AndroidJavaObject javaObject)
        {
            if (javaObject != null)
            {
                PublishRtmChannelMessageResult publishRtmChannelMessageResult = new();
                publishRtmChannelMessageResult.ChannelId = javaObject.Call<string>("getChannelId");
                publishRtmChannelMessageResult.ClientMsgId = javaObject.Call<string>("getClientMsgId");
                publishRtmChannelMessageResult.ServerMsgId = javaObject.Call<string>("getServerMsgId");

                publishRtmChannelMessageResult.Code = javaObject.Call<int>("getCode");
                publishRtmChannelMessageResult.Msg = javaObject.Call<string>("getMsg");

                return publishRtmChannelMessageResult;
            }

            return null;
        }
#endif
    }
}